package cn.hhit.ximalaya.utils;

import android.util.ArrayMap;

import java.util.Map;

import cn.hhit.ximalaya.base.BaseFragment;
import cn.hhit.ximalaya.fragments.HistoryFragment;
import cn.hhit.ximalaya.fragments.RecommendFragment;
import cn.hhit.ximalaya.fragments.SubscriptionFragment;

public class CreatorFragment {
    public final static int INDEX_HISTORY = 2;
    public final static int INDEX_Recommend = 0;
    public final static int INDEX_SUBSCRIPTION = 1;
    //计数器
    public final static int PAGE_COUNT = 3;


    public static Map<Integer, BaseFragment> baseFragmentMap = new ArrayMap<>();

    public static BaseFragment getBaseFragment(int index) {
        BaseFragment fragment = baseFragmentMap.get(index);
        if (fragment != null) {
            return fragment;

        } else {
            switch (index) {
                case INDEX_HISTORY:
                    fragment = new HistoryFragment();
                    break;
                case INDEX_Recommend:
                    fragment = new RecommendFragment();
                    break;
                case INDEX_SUBSCRIPTION:
                    fragment = new SubscriptionFragment();
                    break;
            }
            baseFragmentMap.put(index, fragment);
            return fragment;


        }


    }


}
